<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/javascript.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml" id="teacherForm">
<head>
    <title>批量上传</title>
    <script type="text/javascript">
    var mainform; 

    $(function (){
        mainform=$("#mainform");
        mainform.ligerForm();
        
        //渲染按钮
        LG.setFormDefaultBtn(cancel, save);
        
        //调整form-bar
        $(".form-bar").css("width","630px");
        
        $('#studentFileUpload').uploadify({
    		formData : {
    			"jsessionid": "<%=request.getSession().getId()%>"
			}, 
   	        swf      : '${ctx}/static/uploadify/uploadify.swf',
   	        uploader : '${ctx}/qso/vm/import/upload',
   	        width: 100,
   			height:22,
   			auto: false,
   			fileObjName: 'attachment',
   			fileTypeExts: '*.xls;',
   			fileSizeLimit: 20971520,
   			checkExisting: true,
   			method: 'post',  
   			removeCompleted : false,
   			buttonText:'浏览',
   			queueSizeLimit: 5,
   			displayData: 'percentage',
   			queueID:'student-queue',
   			cancelImg: '${ctx}/static/uploadify/uploadify-cancel.png', 
   			onUploadSuccess : function(file, data, response){
   				 //$("#aid-info").append("文件" + file.name + "上传成功！<br/>");
   			},
   			onQueueComplete: function() {
   				 //$("#aid-info").append("文件全部上传成功！<br/>"); 
   			},
   			onUploadError : function(file, errorCode, errorMsg){
   				 if(errorCode == -200){
   					 $("#student-info").append("文件" + file.name + "大小超过最大限制20M！<br/>");
   				 }
   				 //$("#aid-info").append("文件" + file.name + "上传失败！<br/>");
   			}
   	    });
    	 
    	$('#studentStart').bind('click', function() {
    		$('#studentFileUpload').uploadify('upload','*');
    	});
    });
    
    function save(){
    	LG.submitForm(mainform, function (result) {
        	if(typeof(result)=="string"){
        		result=eval("("+result+")");
        	}
            if (!result.success) {
                LG.showError('错误:' + result.message);
            }
            else { 
                LG.showSuccess('保存成功', function () { 
                   LG.callParent("stuList");
                });
            }
        });
    }
    function cancel(){
        var win = window.parent || window;
        if(win.dialog){
        	win.dialog.close();
        }
    }
 </script>
</head>

<body>
    <form name="mainform" method="post" id="mainform" action="${ctx}/qso/vm/import/save">
        <table cellpadding="0" cellspacing="0" class="l-table-edit" style="width: 95%; margin-top:10px; margin-left:15px;">
            <tr>
				<td align="left" class="l-table-edit-td" valign="top">虚机批量附件：</td>
				<td align="left" class="l-table-edit-td" style="width:80%;">
           			<input type="file" id="studentFileUpload" name="studentFileUpload" > </input>
           			<div id="student-queue"></div>
           			<div id="student-info"></div>
           			<div id="btnCon">
	  					<input type="button" id="studentStart" name="studentStart" value="开始上传" style="margin-left:auto;margin-right: auto;"/>
					</div>
				</td>						
			</tr>
			<tr><td style="width:100%" colspan="2"><a href="${ctx}/static/files/qso_vm.xls">虚机模版下载</a></td></tr>
        </table>       
    </form>
</body>
</html>
